package com.web.type;

import com.service.ArticleTypeService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class AddArticleTypeServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //拿东西
        ArticleTypeService service=new ArticleTypeService();
       // String typename=new String(req.getParameter("typename").getBytes("ISO-8859-1"),"UTF-8");
        String typename=req.getParameter("typename");
        //添加类别
        try {

            service.addType(typename);
            //System.out.println(typename);
            //resp.sendRedirect(req.getContextPath() + "/admin/articletype/list.jsp");
            req.getRequestDispatcher("/ListType").forward(req, resp);

        } catch (Exception e) {
            e.printStackTrace();
        }




    }
}
